//(c) Copyright 2012 Hewlett-Packard Development Company, L.P.
//
//Confidential computer software. Valid license from HP required for possession, use or copying.
//Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, 
//and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.

package com.lp.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;

import com.lp.dao.CollectorInstanceDao;
import com.lp.entity.CollectorInstance;

public class CollectorInstanceDaoImpl implements CollectorInstanceDao {
	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public void add(CollectorInstance ci) {
		sessionFactory.getCurrentSession().persist(ci);
	}

	public void remove(CollectorInstance ci) {
		sessionFactory.getCurrentSession().delete(ci);
	}

	@SuppressWarnings("unchecked")
	public List<CollectorInstance> getCollectorInstances() {
		//return (List<CollectorInstance>) sessionFactory.getCurrentSession().createCriteria(CollectorInstance.class).list();
		return sessionFactory.getCurrentSession().createQuery("from CollectorInstance").list();
	}

}
